<template>
	<view>
		<view>
			<u-navbar title="个人中心" @rightClick="rightClick" :autoBack="true" :bgColor="bgColor"></u-navbar>
		</view>

		<view class="u-page__item">
			<u-cell-group>
				<u-cell title="关于我们" :isLink="true" size="large"></u-cell>
				<u-cell title="用户协议" :isLink="true" size="large"></u-cell>
				<u-cell title="联系我们" :isLink="true" size="large"></u-cell>
				<u-cell title="退出登录" :isLink="true" size="large" @click="outlogin"></u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
	data() {
		return {
			bgColor: '#00dcb9'
		};
	},
	methods: {
		...mapMutations(['updateToken','updateUserInfo']),
		rightClick() {
			console.log('rightClick');
		},
		leftClick() {
			console.log('leftClick');
		},
		outlogin() {
			uni.showModal({
				title: '提示',
				content: '是否要退出登录？',
				success: (res) => {
					if (res.confirm) {
						this.updateToken('');
						this.updateUserInfo({})
						uni.setStorageSync('uid','')
						uni.$showMsg('退出成功！', 1500);
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/home/home'
							})
						}, 1500);
					} else if (res.cancel) {
					}
				}
			});
		}
	},
};
</script>

<style>
.u-page__item {
	margin-top: 78px;
}
</style>
